package com.mkjli.ScheduleManager.dao;

import java.util.HashMap;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.mkjli.ScheduleManager.model.TaskModel;

public class ScheduleDAO {

	@Autowired
	@Qualifier("sqlSessionTemplate")
	SqlSessionTemplate sqlSessionTemplate;

	public void insertTask(TaskModel task) {
		sqlSessionTemplate.insert("task.insertTask", task);
	}

	public TaskModel selectLastTask() {
		return sqlSessionTemplate.selectOne("task.selectLastTask");
	}

	public List<TaskModel> selectTasks(String start, String end) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("start", start);
		param.put("end", end);
		return sqlSessionTemplate.selectList("task.selectTasks", param);
	}

	public void updateTask(TaskModel task) {
		sqlSessionTemplate.update("task.updateTask", task);
	}
}
